use std::collections::HashMap;

#[derive(Debug)]
pub(crate) struct FunctionCallCounter(HashMap<String, u32>);

impl FunctionCallCounter {
    pub(crate) fn new() -> Self {
        Self(HashMap::new())
    }
    /// 返回调用函数计数
    pub(crate) fn call(&mut self, function_name: &str) -> u32 {
        *self
            .0
            .entry(function_name.into())
            .and_modify(|counter| *counter += 1)
            .or_insert(0)
    }
}
